package com.gj.codetools;

import java.lang.ref.WeakReference;

/**
 * Created by gj on 16-1-23.
 */
public class TestWeakHashmap {

    private int i;
    private int j;

    public TestWeakHashmap(int i, int j) {
        this.i = i;
        this.j = j;
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("finalize " + i + " " + j);
    }

    public static void main(String[] args) throws Exception {
        String a = String.format("a %d", 1);
        WeakReference<String> weak1 = new WeakReference<String>(a);
        WeakReference<String> weak2 = new WeakReference<String>(a);
        System.out.println("--> " + (weak1.get() == a));
    }
}
